# url = "ftp://igs.gnsswhu.cn/pub/gps/products/2280/IGS0OPSFIN_20232600000_01D_15M_ORB.SP3.gz"
import numpy as np

from ppgnss import gnss_time

local_dir = "./data"
year_from, doy_from = 2022, 355
year_to, doy_to = 2023, 11

jd_from = gnss_time.doy2jd(year_from, doy_from)
jd_to = gnss_time.doy2jd(year_to, doy_to)

for jd in np.arange(jd_from, jd_to+1):
    year, doy = gnss_time.jd2doy(jd)
    gpsw, gpsd = gnss_time.jd2gpsw(jd)
    url = "ftp://igs.gnsswhu.cn/pub/gps/products/%04d/IGS0OPSFIN_%04d%03d0000_01D_15M_ORB.SP3.gz" %(
        gpsw, year, doy
    )
    cmd = "wget -P %s %s" %(local_dir, url)
    print(cmd)
    # break